var addTwoNumbers = function(l1,l2){
  let stack1 = [];
  let stack2 = [];
  let head = null;
  let carry = 0;
  while(l1.next !== null){
    stack1.push(l1.val);
    l1 = l1.next;
  }
  while(l2.next !== null){
    stack2.push(l2.val);
    l2 = l2.next;
  }
  while(stack1.length !== 0 || stack2.length !== 0){
    let num = 0;
    if(stack1.length !== 0){
      num += stack1.pop();
    }
    if(stack2.length !== 0){
      num +=stack2.pop();
    }
    num +=carry;
    const node = new listNode(num % 10);
    carry = Math.floor(num/10);
    node.next = head;
    head = node;

  }
  if(carry != 0){
    const node = new listNode(carry);
    node.next = head;
    head = node;
  }
  return head;
}